import React, { useCallback, useEffect } from "react";
import { Input, Button, Row, Col, Layout, Divider, Form } from 'antd';
import request from "../../utils/request";
import { connect } from "react-redux";
const { TextArea } = Input;
const { Sider, Content } = Layout;
function Forum({ user }) {
    // console.log(user.userInfo.id);
    const id = user.userInfo.id
    const username = user.userInfo.username
    // useEffect(() => {
    //     request({
    //         url: '/comment/addComment',
    //         params: {
    //             comment: 'sadasda',
    //             id,
    //             mivieID: '015324'
    //         }
    //     }).then
    // }, [])
    const onFinish = useCallback((e) => {
        // console.log(e);
        // console.log(e);
        const {comment} = e
        request({
                    url: '/comment/addComment',
                    method:'post',
                    data: {
                        comment,
                        id,
                        movieID: '015324',
                        username
                    }
                }).then(res=>{
                    console.log(res);
                })
    })
    return (
        <>
            <Layout className="layout">
                <Sider theme='light' width='300px'>
                    <h3 style={{ float: "left" }}>求片</h3>
                    <h5>审核开启,并非留言失败</h5>


                    <Form
                        name="basic"
                        labelCol={{
                            span: 8,
                        }}
                        wrapperCol={{
                            span: 16,
                        }}
                        initialValues={{
                            remember: true,
                        }}
                        onFinish={onFinish}

                        autoComplete="off"
                    >
                        <Form.Item
                            name="comment"
                            rules={[
                                {
                                    required: true,
                                    message: '',
                                },
                            ]}
                            wrapperCol={{
                                span: 16,
                            }}
                        >
                            <TextArea size={'large'} />
                        </Form.Item>
                        <Form.Item>
                            <Button className="btn" block={true} type="primary" htmlType="submit"  size={'middle'} style={{ background: '#25252b' }}>
                                提交
                            </Button>
                        </Form.Item>
                    </Form>
                </Sider>

                <Layout >
                    <Content style={{ paddingRight: '50%', background: '#fff', textAlign: 'left' }}>
                        <div>
                            <h1>公告</h1>
                            <Divider />
                            <p>1. 片源以磁力为主,无磁力才使用115</p>
                            <p>2. 求片以电影为主,不保证其他类型成功率</p>
                            <p>3. 版权原因,不更当年国产影片</p>
                        </div>
                        <Divider />
                        <div>
                            <h4>wj410324</h4>
                            <p>求电影“黑鹰少年”，谢谢</p>
                            <p>2022-10-14 14:00:24</p>
                        </div>
                        <Divider />
                        <div>
                            <h4>wj410324</h4>
                            <p>求电影“黑鹰少年”，谢谢</p>
                            <p>2022-10-14 14:00:24</p>
                        </div>
                        <Divider />
                        <div>
                            <h4>wj410324</h4>
                            <p>求电影“黑鹰少年”，谢谢</p>
                            <p>2022-10-14 14:00:24</p>
                        </div>
                        <Divider />
                        <div>
                            <h4>wj410324</h4>
                            <p>求电影“黑鹰少年”，谢谢</p>
                            <p>2022-10-14 14:00:24</p>
                        </div>
                        <Divider />
                        <div>
                            <h4>wj410324</h4>
                            <p>求电影“黑鹰少年”，谢谢</p>
                            <p>2022-10-14 14:00:24</p>
                        </div>
                        <Divider />

                    </Content>
                </Layout>
            </Layout>
        </>


    )
}


const mapStateToProps = function (state) {
    // console.log(state);
    return {
        user: state
    }
}

// 把修改redux的方法映射到props
const mapDispatchToProps = function (dispatch) {
    return {}
}
Forum = connect(mapStateToProps, mapDispatchToProps)(Forum)
export default Forum